<div class="resources">
<h1><?php h($this->get_title()) ?></h1>
<?php
if(isset($Resources)):
$resources = $Resources->value();
$labels = $this->get_labels($resources);
$count = array('res'=>0,'prop'=>0,'ob'=>0);
?>
<?php include('elements/response.html') ?>
<a class="action view" rel="view back" href="/?<?php h($_SERVER['QUERY_STRING'])?>">Back</a>

<form action="" method="post" class="edit">
	<ol>
<?php foreach($Resources->value() as $uri => $properties): ?>
<?php $count['res']++?>
<li><fieldset class="-rdf-Resource" id="res_<?php h($count['res']) ?>">
	<h2 class="dc-title"><?php echo $Resources->to_resource($uri)->get_title() ?></h2>
	<dl>	
	<?php foreach($properties as $property => $objects): ?>
	<?php $count['prop']++?>
		<dt><label for="n<?php echo implode('_',$count)?>"><?php h($labels[$property])?></label></dt>
		
		<?php  foreach($objects as $object): ?>
		
			<?php
			 
				$p_key = $property;
				$p_key.= !empty($object['datatype'])? '^^'.$object['datatype'] : '';
				$p_key.= isset($object['lang'])? '@'.$object['lang'] : ''; 
			 ?>
		
			<dd>		
			<?php switch($object['type']):
				default:
			 	case 'uri': ?>
					<input 
					class="resource"
					name="resources[<?php echo $uri ?>][<?php h($property)?>][<?php echo $count['ob']?>][rdf:resource]" 
					value="<?php h($object['value'])?>"
					id="n<?php echo implode('_',$count)?>"
					/>
					<?php break; 
				 case 'literal': ?>
				<?php if(strlen($object['value']) < 40):?>
					<input 
					class="literal"
					name="resources[<?php h($uri) ?>][<?php h($p_key) ?>][<?php echo $count['ob']?>]" 
					value="<?php h($object['value'])?>"
					id="n<?php echo implode('_',$count)?>"
					/>
				<?php else:?>
					<textarea
					class="literal"
					rows="10" cols="30"
					name="resources[<?php h($uri) ?>][<?php h($p_key) ?>][<?php echo $count['ob']?>]" 
					id="n<?php echo implode('_',$count)?>"
					><?php h($object['value'])?></textarea>
				<?php endif?>
					<?php break; 
				 case 'bnode': ?>
				
				<input 
				class="resource bnode"
				name="resources[<?php h($uri) ?>][<?php h($property)?>][<?php echo $count['ob']?>][rdf:nodeID]" 
				value="<?php h($object['value'])?>"
				id="n<?php echo implode('_',$count)?>"
				/>
				
				
				
					<?php break;
			 	endswitch?>
			</dd>
		<?php $count['ob']++?>	
			
			
		<?php endforeach ?>
	<?php endforeach ?>
	</dl>
</fieldset></li>
<?php endforeach?>
</ol>

<?php include('elements/send-data.html') ?>
<div>
	<input type="submit" value="Edit"/>
</div>

</form>
</div>
<?php endif?>
<?php include('elements/fetch-form.html') ?>